﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OutpatientManage.aspx.cs" Inherits="RegisterWeb.Manager.DoctorPersonalCenter.OutpatientManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
  

    
<script type="text/javascript">
   
    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        // alert(result);
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

    $(function () {
      

        //预加载编辑框
        $("#addOutpatient").dialog('refresh');
        $("#addOutpatient").dialog({
            modal: true,
            "title": "新建患者就诊信息",
            width: 600,
            height: 400,
            href: 'AddOutpatient.aspx'
        });
        $("#addOutpatient").dialog('open').dialog('close');

        $("#seePatient").dialog('refresh');
        $("#seePatient").dialog({
            modal: true,
            "title": "查看患者就诊信息",
            width: 480,
            height: 400,
            href: 'SeeOutpatientInfo.aspx'
        });
        $("#seePatient").dialog('open').dialog('close');

        //条件查询窗口
        $("#searchPatient").dialog({
            modal: true,
            "title": "条件查询就诊信息",
            width: 800,
            height: 550,
            href: 'SearchPatientInfo.aspx'
        });
        $("#searchPatient").dialog('open').dialog('close');
    
    });

    function checkOutpatient() {
        
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.post('ashx/OutpatientHandler.ashx?action=checkPatient', { action: 'checkPatient', id: row.Register_ID }, function (data, status) {
                if (data == 'no') {

                    $('#addOutpatient').dialog('open');

                        $("#Outpatient_PaitentName").val(row.Register_PatientName);
                        $("#Outpatient_PaitentSex").combobox('setValue', row.Register_PaintSex);
                        $('#Outpatient_PaitentBirthDay').datebox('setValue', row.Register_BirthDay);
                        $('#Outpatient_PaitentIDCards').val(row.Register_IDCards);
                        $("#Outpatient_OutpaitentType").combobox('setValue', row.OutpatientTypeValue);
                    
                        url = 'ashx/OutpatientHandler.ashx?action=addOutpatient&id=' + row.Register_ID;
                        formId = "#add";
                        dialogId = "#addOutpatient";

               
                }
                else {
                    $.messager.alert("提示", "此号已存在就诊信息，请重新挂号!", "info");
                }
            });
        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");

        }
    }
    //查看就诊信息
    function SeeOutpatient() {
      
        var row = $('#dg').datagrid('getSelected');
        if (row) {
          
           $.post('ashx/OutpatientHandler.ashx?action=checkPatient', { action: 'checkPatient', id: row.Register_ID }, function (data, status) {
               if (data == 'ok') {
            $.post('ashx/OutpatientHandler.ashx?action=seeOutpatient', { action: 'seeOutpatient', id: row.Register_ID }, function (data, status) {
                $('#seePatient').dialog('open');

                $('#Outpatient_PaitentName').text(data[0].Outpatient_PaitentName);
                $('#Outpatient_PaitentSex').text(data[0].Outpatient_PaitentSex);
                $('#Outpatient_PaitentBirthDay').text(data[0].Outpatient_PaitentBirthDay);
                $('#Outpatient_PaitentIDCards').text(data[0].Outpatient_PaitentIDCards);
                $('#Outpatient_OutpaitentType').text(data[0].Outpatient_OutpaitentType);
                $('#Outpatient_MainIntroduce').text(data[0].Outpatient_MainIntroduce);
                $('#Outpatient_ShowHistory').text(data[0].Outpatient_ShowHistory);
                $('#Outpatient_PastHistory').text(data[0].Outpatient_PastHistory);
                $('#Outpatient_Recoder').text(data[0].Outpatient_Recoder);
                $('#Outpatient_AddTime').text(data[0].Outpatient_AddTime);
                formId = "#see";
                dialogId = "#seePatient";

            }, "JSON");
               }
                else {
                    $.messager.alert("提示", "此患者尚未就诊!", "info");
                }
            });
        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");

        }
    }
   
    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: successCallback
        });
    }

  
    function Search() {


        $('#searchPatient').dialog('open');
        var outpatientTimeFrom = $("#outpatientTimeFrom").datebox('getValue');
        var outpatientTimeTo = $("#outpatientTimeTo").datebox('getValue');
        var patientName = $("#patientName").val();
        
        //如果开始时间比结束时间迟，不给提交，如果开始时间为空，结束时间不为空，不给提交
       $('#dg1').datagrid('options').pageNumber = 1;
        $('#dg1').datagrid('getPager').pagination({ pageNumber: 1 });
        $('#dg1').datagrid('options').url = 'ashx/OutpatientHandler.ashx?action=search&outpatientTimeFrom='+outpatientTimeFrom+'&outpatientTimeTo='+outpatientTimeTo+'&patientName='+patientName;

      
       
        $('#dg1').datagrid("reload");
    }

</script>

</head>
<body>
    <form id="form1" >
    <div region="center" title="患者就诊信息管理" >
<table id="dg" title="患者就诊信息管理" class="easyui-datagrid" style="overflow:auto ; height:550px"
			url="ashx/OutpatientHandler.ashx?action=get"
			toolbar="#toolbar"  pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true" 
            pageSize="20"
            >
		<thead>
			<tr>
			    <th field="Register_IDCode" width="50" >挂号编号</th>

				<th idField="Register_ID" width="50"  hidden="true">编号</th>

                <th field="Register_Number" width="50">第几号</th>
                <th field="OutpatientType" width="50">门诊类型</th>
                <th field="OutpatientTypeValue" widht="20" hidden="true">门诊值</th>
                <th field="Register_PatientName" width="50">患者姓名</th>
				
                 <th field="Register_PaintSex"  width="20">性别</th>

                 <th field="Register_BirthDay"  width="50">出生日期</th>

                 <th field="Register_IDCards"  width="50">身份证号</th>
                 
                <!-- <th field="Outpatient_OutpaitentType"  width="50">门诊类型</th>-->

                 <th field="Register_IsClinic"  width="50"> 是否就诊</th>
                 
               
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="checkOutpatient()">添加就诊信息</a>
                    <a href="#" class="easyui-linkbutton"  plain="true" onclick=" SeeOutpatient()">
                        <img src="../../images/user_magnify.png" />查看就诊信息</a>
                    
                    <span  style="float:right; position:relative">就诊时间:
                    <input id="outpatientTimeFrom" style="line-height:26px;border:1px solid #ccc" class="easyui-datebox" /> — 
                    <input id="outpatientTimeTo" style="line-height:26px;border:1px solid #ccc" class="easyui-datebox" />
                 
               
                    &nbsp;  
                      患者姓名:
                  <input id="patientName" style="line-height:26px;border:1px solid #ccc" class="easyui-validatebox" />  
                  <a href="#" class="easyui-linkbutton" plain="true"  iconCls="icon-search" onclick="Search()" >查询</a>
                    </span>
    </div>

              <div id="seePatient" class="easyui-dialog" closed="true" buttons="#seePatient-buttons" style="padding:10px 20px">
        	</div>
          
             <div id="seePatient-buttons">
			
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#seePatient").dialog("close");'>关闭</a>
			</div>

            <div id="addOutpatient" class="easyui-dialog" closed="true" buttons="#addOutpatient-buttons" style="padding:10px 20px">
        	</div>
          
             <div id="addOutpatient-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok"  onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#addOutpatient").dialog("close");'>关闭</a>
			</div>
               <div id="searchPatient" class="easyui-dialog" closed="true" buttons="#searchPatient-buttons" style="padding:10px 20px">
        	</div>
          
             <div id="searchPatient-buttons">
			
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#searchPatient").dialog("close");'>关闭</a>
			</div>
    </div>
    </form>
</body>
</html>

